from django.urls import path
from rest_framework.routers import DefaultRouter
from . import views

urlpatterns = [
    path('books/', views.BookListView.as_view()),
    path('books/<int:pk>/', views.BookDetailView.as_view()),
    path('api/books/', views.BookListAPIView.as_view()),
    path('genericapi/books/', views.BookListGenericAPIView.as_view()),
    path('genericapi/books/<int:pk>/', views.BookListDetailAPIView.as_view()),
    path('mixinapi/books/', views.BookListMixinAPIView.as_view()),
    path('mixinapi/books/<int:pk>/', views.BookListRetrieveModelAPIView.as_view()),
    path('listapi/books/', views.BookListCreateAPIView.as_view()),
    path('listapi/books/<int:pk>/', views.BookListRetrieveAPIView.as_view()),

    # 视图集
    path('viewset/books/', views.BookViewSet.as_view({'get': 'list'})),
    path('viewset/books/<int:pk>/', views.BookViewSet.as_view({'get': 'retrieve'})),
]

# 视图集
router = DefaultRouter()
router.register('Bookmodelviewset', views.BookModelViewSet, basename='Bookmodelviewset')
router.register('Peploemodelviewset', views.PeploeModelViewSet, basename='Peploemodelviewset')

urlpatterns += router.urls
